{include file="public/header" /}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">设备和量具</a>
        <a>
          <cite>设备管理</cite>
        </a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <xblock>
        <a class="layui-btn"  target="_blank" href="{:url()}"><i class="iconfont">&#xe718;</i> 框架页面</a>
        <button class="layui-btn" onclick="x_admin_show('添加设备','{:url(\'index/Equipment/addEquipmentInfo\')}')"><i class="layui-icon"></i>添加设备</button>
        <button class="layui-btn"  onclick="openLinke()">维修保养记录</button>
        <div class="layui-input-inline">
            <form class="layui-form" action="{:url('index/Equipment/equipmentInfo')}" method="post">
                <div class="layui-input-inline">
                    <input type="text" name="modules" autocomplete="off" placeholder="请输入关键字..." class="layui-input">
                </div>
                <div class="layui-input-inline">
                    <select name="id" lay-search="" >
                        <option value=""></option>
                        <optgroup label="设备类型">
                            {volist name="$equipmentType" id="equipmentTypeList"}
                            <option value="{$equipmentTypeList.id}">{$equipmentTypeList.eqpmt_type}</option>
                            {/volist}
                        </optgroup>
                    </select>
                </div>
                <button type="submit" class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
            </form>
        </div>
        <span class="x-right" style="line-height:40px">共{$equipmentInfoCount}条 · 共{$equipmentInfoCount/25|getInt}页</span>
    </xblock>
    <div class="container-wrap">
        <div class="box-1">
            <table class="layui-table">
                <thead>
                <tr>
                    <th width="2%">操作</th>
                    <th>编号</th>
                    <th>类型</th>
                    <th>名称</th>
                    <th>模型</th>
                    <th>生产地</th>
                    <th>生产日期</th>
                    <th>购买日期</th>
                    <th>购买价格</th>
                    <th>当前价值</th>
                    <th>正在运行</th>
                    <th>卖出日期</th>
                    <th>使用者</th>
                </tr>
                </thead>
                <tbody>
                {volist name="$equipmentInfo" id="equipmentInfoList"}
                <tr>
                    <td class="td-manage" width="50px;">
                        <a title="编辑"onclick="x_admin_show('修改设备','{:url(\'index/Equipment/editEquipmentInfo\',[\'id\'=>$equipmentInfoList.id])}')" href="javascript:;">
                            <i style="color: green" class="layui-icon"></i>
                        </a>
                        <a title="删除" onclick="delete_(this,'{$equipmentInfoList.id}')" href="javascript:;">
                            <i  style="color:red;" class="layui-icon"></i>
                        </a>
                        <a title="保养" onclick="x_admin_show('{$equipmentInfoList.eqpmt_id}的保养记录','{:url(\'index/EquipmentRepair/repairInfo\',[\'eqpmt_id\'=>$equipmentInfoList.eqpmt_id])}')" href="javascript:;">
                            <i style="color:green;" class="iconfont">&#xe707;</i>
                        </a>
                        <a title="维修" onclick="x_admin_show('{$equipmentInfoList.eqpmt_id}的维修记录','{:url(\'index/EquipmentMaintain/maintainInfo\',[\'eqpmt_id\'=>$equipmentInfoList.eqpmt_id])}')" href="javascript:;">
                            <i style="color:red;" class="iconfont">&#xe709;</i>
                        </a>
                    </td>
                    <td>{$equipmentInfoList.eqpmt_id}</td>
                    <td>{$equipmentInfoList.eqpmt_type_id|getEquipmentName}</td>
                    <td>{$equipmentInfoList.eqpmt_name}</td>
                    <td>{$equipmentInfoList.eqpmt_model}</td>
                    <td>{$equipmentInfoList.manufacturer}</td>
                    <td>{$equipmentInfoList.manufacture_date}</td>
                    <td>{$equipmentInfoList.purchasing_date}</td>
                    <td>{$equipmentInfoList.price}</td>
                    <td>{$equipmentInfoList.current_price}</td>
                    <td>{$equipmentInfoList.is_working?'<span class="layui-badge layui-bg-green">是</span>':'<span class="layui-badge">否</span>'}  </td>
                    <td>{$equipmentInfoList.sell_date}</td>
                    <td>{$equipmentInfoList.user}</td>
                </tr>
                {/volist}
                </tbody>
            </table>
        </div>
    </div>
    <div class="page">
        {$equipmentInfo|raw}
    </div>

</div>
<script>
    /*删除*/
    function delete_(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            var url = "{:url('/index/Equipment/delete')}";
            var postData ={"id":id};
            $.post(url,postData,function (result) {
                if(result === 1){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                }else {
                    layer.alert("删除失败", {icon: 5});
                }
            },"json");
        });
    }

    function openLinke() {
        layer.confirm('请选择要查看的记录', {
                btn: ['保养','维修'] //按钮
            }, function(){
                x_admin_show('保养记录',"{:url('index/EquipmentRepair/allRepairInfo')}");
                layer.msg('保养', {
                    time: 500, //20s后自动关闭
                });
            }, function(){
                x_admin_show('维修记录',"{:url('index/EquipmentMaintain/allMaintainInfo')}");
                layer.msg('维修', {
                    time: 500, //20s后自动关闭
                });
            }
        );
    }
</script>
</body>
</html>